package com.mzx.javase.io;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 类描述：对象输入流，将序列化在硬盘上的数据恢复到内存中
 *
 * @ClassName ObjectInputStreamTest
 * @Description TODO
 * @Author 马子鑫
 * @Date 2022/7/31 20:28
 * @Version 1.0
 */
public class ObjectInputStreamTest {
    public static void main(String[] args) {
        ObjectInputStream ois = null;
        try {
            ois = new ObjectInputStream(new FileInputStream("emploee.txt"));
            Employee o = (Employee)ois.readObject();
            System.out.println(o);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } finally {
            if (ois != null) {
                try {
                    ois.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
